home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / GZIP107S.ZIP;1 / GZIP107.TAR / gzip-1.0.7 / zdiff.in < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.8 KB  |  69 lines

  1. :
  2. #!/bin/sh
  3.  
  4. # Zcmp and zdiff are used to invoke the cmp or the  diff  pro-
  5. # gram  on compressed files.  All options specified are passed
  6. # directly to cmp or diff.  If only 1 file is specified,  then
  7. # the  files  compared  are file1 and an uncompressed file1.z.
  8. # If two files are specified, then they are  uncompressed  (if
  9. # ending  with  ".z") and fed to cmp or diff.  The exit status
  10. # from cmp or diff is preserved.
  11.  
  12. prog=`echo $0 | sed 's|.*/||'`
  13. case "$prog" in
  14.   *cmp) comp=${CMP-cmp}   ;;
  15.   *)    comp=${DIFF-diff} ;;
  16. esac
  17.  
  18. OPTIONS=
  19. FILES=
  20. for ARG
  21. do
  22.     case "$ARG" in
  23.     -*)    OPTIONS="$OPTIONS $ARG";;
  24.      *)    if test -f "$ARG"; then
  25.             FILES="$FILES $ARG"
  26.         else
  27.             echo "${prog}: $ARG not found or not a regular file"
  28.         exit 1
  29.         fi ;;
  30.     esac
  31. done
  32. if test -z "$FILES"; then
  33.     echo "Usage: $prog [${comp}_options] file [file]"
  34.     exit 1
  35. fi
  36. set $FILES
  37. if test $# -eq 1; then
  38.     FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'`
  39.     gzip -cd "$1" | $comp $OPTIONS - "$FILE"
  40.     STAT="$?"
  41.  
  42. elif test $# -eq 2; then
  43.     case "$1" in
  44.         *[-.][zZ] | *.t[ga]z)
  45.                 case "$2" in
  46.             *[-.][zZ] | *.t[ga]z)
  47.             F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*$||'`
  48.                         gzip -cd "$2" > /tmp/"$F".$$
  49.                         gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$
  50.                         STAT="$?"
  51.             /bin/rm -f /tmp/"$F".$$;;
  52.  
  53.                 *)      gzip -cd "$1" | $comp $OPTIONS - "$2"
  54.                         STAT="$?";;
  55.                 esac;;
  56.         *)      case "$2" in
  57.             *[-.][zZ] | *.t[ga]z)
  58.                         gzip -cd "$2" | $comp $OPTIONS "$1" -
  59.                         STAT="$?";;
  60.                 *)      $comp $OPTIONS "$1" "$2"
  61.                         STAT="$?";;
  62.                 esac;;
  63.     esac
  64.         exit "$STAT"
  65. else
  66.     echo "Usage: $prog [${comp}_options] file [file]"
  67.     exit 1
  68. fi
  69.